load("//publish:defs.bzl", "release_strip_binary")

package(default_visibility = ["//rs:ic-os-pkg"])

OBJECTS = {
    "fstrim_tool": "//rs/ic_os/fstrim_tool:fstrim_tool_bin",
    "guestos_tool": "//rs/ic_os/os_tools/guestos_tool:guestos_tool",
    "guest_vm_runner": "//rs/ic_os/os_tools/guest_vm_runner",
    "guest_vm_runner_dev": "//rs/ic_os/os_tools/guest_vm_runner:guest_vm_runner_dev",
    "hostos_tool": "//rs/ic_os/os_tools/hostos_tool",
    "hostos_tool_dev": "//rs/ic_os/os_tools/hostos_tool:hostos_tool_dev",
    "nft-exporter": "//rs/ic_os/nft_exporter:nft-exporter",
    "setupos_tool": "//rs/ic_os/os_tools/setupos_tool:setupos_tool",
    "config": "//rs/ic_os/config:config",
    "config_dev": "//rs/ic_os/config:config_dev",
    "vsock_guest": "//rs/ic_os/vsock/guest:vsock_guest",
    "vsock_host": "//rs/ic_os/vsock/host:vsock_host",
    "metrics-proxy": "@crate_index//:metrics-proxy__metrics-proxy",
    "nss_icos": "//rs/ic_os/nss_icos",
    "metrics_tool": "//rs/ic_os/metrics_tool:metrics_tool_bin",
}

[release_strip_binary(
    name = name + "_stripped",
    binary = OBJECTS[name],
) for name in OBJECTS]

[
    genrule(
        name = name + "_cleaned",
        srcs = [name + "_stripped"],
        outs = [name],
        cmd = select({
            "@platforms//os:linux": "objcopy -R .comment -R .note -R .note.gnu.build-id $< $@",
            "@platforms//os:osx": "cp $< $@",
        }),
        executable = True,
    )
    for name in OBJECTS
]
